﻿
using System;
using System.Collections.Generic;
using System.Text;

using YouHP.Utility;
using YouHP.BLL;
using YouHP.Model;
using YouHP.Model.Group;
using System.Web;

namespace YouHP.Pages
{
    public class Tag:BasePage
    {
        protected override void ShowPage()
        {
            base.ShowPage();
            if (ErrorCount > 0) return;

            HandleCommon();
            if (ErrorCount > 0) return;

            if (IsPost) HandlePost();
            else HandleGet();
        }
        protected List<TopicInfo> topiclist = new List<TopicInfo>();
        protected int n = 8;


        protected int PageCount;
        protected int PageIndex;
        protected int PageSize = 20;
        protected string PagingString = "";
        protected int DataCount = 0;
        protected List<LogTopicInfo> logTopicList = new List<LogTopicInfo>();


        protected int PageCount1;
        protected int PageIndex1;
        protected int PageSize1 = 20;
        protected string PagingString1 = "";
        protected int DataCount1 = 0;
        protected string tagName = null;




        protected void HandleCommon()
        {
            tagName = RequestTools.GetString("tagname");

            this.SetTitle("标签");
            this.AddLocation("标签", "/BoardTag.aspx");
            this.SetTitle(tagName);
            this.AddLocation(tagName, "/Tag.aspx?tagname="+tagName);
        }

        protected void HandlePost()
        {
                //获取帖子操作的行为
   
                   
        }

        protected void HandleGet()
        {




            PageIndex = RequestTools.GetQueryInt("page", 1);
            topiclist = TagBLL.Instance.GetTopicListByTag(20, PageIndex, tagName, out DataCount);

            PageCount = Utils.GetPageCount(DataCount,20);

            PageIndex1 = RequestTools.GetQueryInt("page1", 1);
            logTopicList = TagBLL.Instance.GetLogTopicListByTag(20, PageIndex1, tagName, out DataCount1);

            PageCount1 = Utils.GetPageCount(DataCount1, 20);
            string query = HttpContext.Current.Request.Url.Query;
            query = Utils.RemoveQueryItem(query, "page");
            query = Utils.RemoveQueryItem(query, "page1");

            PagingString = this.GetPagingString(
                PageIndex,
                PageCount,
                "/Tag.aspx" + query + "&page1="+PageIndex1, "page");

            PagingString1 = this.GetPagingString(
                PageIndex1,
                PageCount1,
                "/Tag.aspx" + query+"&page="+PageIndex, "page1");

        }
    }
}